// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import './assets/iconfont/iconfont.css'
import './assets/styles/reset.css'
import store from './store'
import VueCordova from 'vue-cordova'
import VueI18n from 'vue-i18n'

Vue.config.productionTip = false

// 全局设置分辨率(devicePixelRatio)
// 入口文件处设置
Vue.prototype.$devicePixelRatio = 2

Vue.use(VueCordova);
// add cordova.js only if serving the app through file://
if (window.location.protocol === 'file:' || window.location.port === '3000') {
  var cordovaScript = document.createElement('script')
  cordovaScript.setAttribute('type', 'text/javascript')
  cordovaScript.setAttribute('src', 'cordova.js')
  document.body.appendChild(cordovaScript)
}

Vue.use(VueI18n);
const i18n = new VueI18n({
  locale: 'zh-CN', // 语言标识
  // locale: 'en-US', // 语言标识
  //this.$i18n.locale // 通过切换locale的值来实现语言切换
  messages: {
    'zh-CN': require('./common/lang/zh'), // 中文语言包
    'en-US': require('./common/lang/en') // 英文语言包
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: {
    App
  },
  template: '<App/>',
  data() {
    return {
      cordova: Vue.cordova
    }
  }
})
